class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int> stck;
        set<string> st = { "+", "-", "*", "/" };
        for (auto& str : tokens)
        {
            if (st.find(str) != st.end())
            {
                int tmp1 = stck.top();
                stck.pop();
                int tmp2 = stck.top();
                stck.pop();
                switch (str[0])
                {
                case '+':
                    stck.push(tmp1 + tmp2);
                    break;
                case '-':
                    stck.push(tmp2 - tmp1);
                    break;
                case '*':
                    stck.push(tmp1 * tmp2);
                    break;
                case '/':
                    stck.push(tmp2 / tmp1);
                    break;
                }
            }
            else
                stck.push(stoi(str));
        }
        return stck.top();
    }
};